import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
import { consts } from '@yolanda-qn/eight-electrodes-report-lib';

@Component({})
export default class extends Vue {
  @Prop() reportItem!: Record<string, any>;
  @Prop({ default: false }) isSavingImg!: boolean;
  showDetail = false;
  @Watch('isSavingImg')
  watchIsSavingImg(nextValue: boolean) {
    if (nextValue) {
      this.showDetail = false;
    }
  }
  handleChangeShowDetail() {
    this.showDetail = !this.showDetail;
  }

  get computedCurrentLevel() {
    let detail = null;
    if (this.reportItem.processBarVisible) {
      detail = this.reportItem.levels[this.reportItem.levelIndex];
    }
    return detail;
  }

  get computedValue() {
    if (this.reportItem.id === consts.ReportBuilderIdsEnum.FattyLiver) {
      const valueTextMapping: Record<string, string> = {
        0: '0',
        1: 'I',
        2: 'II',
        3: 'III',
        4: 'IV',
      };

      return valueTextMapping[this.reportItem.value];
    }

    return this.reportItem.value;
  }
}
